import i18n from 'i18next';
import { initReactI18next } from 'react-i18next';
import LanguageDetector from 'i18next-browser-languagedetector';
import zhCN from '../locales/zh_CN';
import zhTW from '../locales/zh_TW';
import enUS from '../locales/en_US';

const resources = {
  zh_CN: {
    translation: zhCN,
  },
  zh_TW: {
    translation: zhTW,
  },
  en_US: {
    translation: enUS,
  },
};

i18n
  .use(LanguageDetector)
  .use(initReactI18next)
  .init({
    resources,
    lng: 'zh_CN', // 默认语言
    fallbackLng: 'zh_CN',
    interpolation: {
      escapeValue: false,
    },
    detection: {
      order: ['localStorage', 'navigator'],
      caches: ['localStorage'],
    },
  });

export default i18n; 